package cn.itcast.order;


import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

//feign的自定义配置：如果要全局生效，将其放到启动类的@EnableFeignClients这个注解中：
//@EnableFeignClients(defaultConfiguration = DefaultFeignConfiguration.class)

@EnableFeignClients(basePackages = "cn.itcast.feign.clients")
@MapperScan("cn.itcast.order.mapper")
@SpringBootApplication
public class OrderApplicationTest {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplicationTest.class, args);
    }


    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    //TODO: 自定义负载均衡策略 （1.代码方式）
//    @Bean
//    public IRule randomRule() {
//        return new RandomRule();
//    }
}